package com.ecable.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Vector;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ecable.bean.PackagesTO;
import com.ecable.daoImpl.PackagesDaoImpl;
import com.ecable.util.UtilConstants;

public class PackRegConnectionAction extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String path = "";
		RequestDispatcher rd = null;
		Vector<PackagesTO> vpack = new Vector<PackagesTO>();
		try {
			vpack = new PackagesDaoImpl().viewPackReg();
		} catch (Exception le) {
			request.setAttribute("status", UtilConstants._NO_PACKAGE);
			rd = request.getRequestDispatcher(UtilConstants._Connection_FAILED);
		}
		if (!vpack.isEmpty()) {
			request
					.setAttribute("status",
							UtilConstants._APPLY_CONNECTION_FAIL);
			request.setAttribute("packs", vpack);
			path = UtilConstants._REG_CONNECTION;
		} else {
			request.setAttribute("status", UtilConstants._Connection_FAILED);
			path = UtilConstants._REG_CONNECTION;
		}
		rd = request.getRequestDispatcher(path);
		rd.forward(request, response);
	}
}
